import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
/**
 * Created by 罗天瑞 on 2016/10/29.
 */
public class CutImage {
    public void CutImage()
    {
        try
        {
            BufferedImage image = ImageIO.read(new File("data/wallpaper.jpg"));
            int Width = image.getWidth();
            int Height = image.getHeight();
            int[] ImageArray = new int[Width*Height];
            image.getRGB(0,0,Width,Height,ImageArray,0,Width);

            BufferedImage Newimage = new BufferedImage(Width/2,Height,BufferedImage.TYPE_INT_RGB);
            Newimage.setRGB(0,0,Width/2,Height,ImageArray,0,Width);
            File output = new File("data/Newwallpaper.jpg");
            ImageIO.write(Newimage,"jpg",output);

            for(int i = 0;i<Width/2;i++)
            {
                for(int j=0;j<Height;j++)
                {
                    getARGB(Newimage.getRGB(i,j));
                }
            }
        }
        catch(IOException e)
        {
            e.printStackTrace();
        }
    }

    public static void getARGB(int pixel)
    {
        int a = (pixel>>24) & 0xff;
        int r = (pixel>>16) & 0xff;
        int g = (pixel>>8) & 0xff;
        int b = (pixel) & 0xff;
    }
}
